chore(dashboard): fix bugs found in dashboard review - #135
Merged
Conversation
The traces panel on the pipeline editor dereferenced p.Pipeline.Id unconditionally, panicking when rendering the create page (Pipeline is nil). Hide the panel when there is no pipeline yet. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… prints Avoid nil resp.Body deref, return after surfacing an error instead of falling through to a nil-deref status check, and remove stray fmt.Printf debug output. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…e copy Avoid an out-of-range panic when WorkerTimes is shorter than Workers, and fix the duplicated/ungrammatical hour branches in formatSince. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… fix datastream ws error handling Build full next-page URLs (with sensor_group when filtered) instead of bare cursors; add missing returns after start/end parse errors in the datastream websocket; close per-frame websocket writers instead of deferring in a loop. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add middleware.Recoverer so handler/template panics return a clean 500 instead of dropping the connection, and remove a stray nosurf reason debug print. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…le on create, drop debug prints Always send the worker description so it can be cleared, set state from the Enabled checkbox when creating a worker, and remove stray fmt.Println debug output. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Combines six independent fixes from the dashboard review: - guard pipeline create page against nil Pipeline (panic) - preserve sensor_group in device pagination + datastream ws returns - correct pipeline update error handling + drop debug prints - guard trace worker-time indexing + fix relative-time copy - allow clearing worker description, honor enabled toggle on create - add panic recovery middleware + drop debug print Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…tion - surface API error messages and real status codes for pipeline create/update via a shared handleAPIClientError helper; remove dead error branches - only send worker description when present in the form so an omitted field no longer erases the stored description - log nosurf CSRF rejections with reason and return 400 instead of silent 200 - deduplicate device-table next-page URL construction into one helper - deduplicate worker state checkbox mapping into formState - fix 'About 1 seconds ago' pluralization and clamp negative durations Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UyNzyujudsPcubHodWnzp9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a batch of bugs found during a review of the dashboard web app. Each fix was developed in an isolated worktree and merged together; the combined branch builds, vets, and is
gofmt-clean.Fixes
Critical
p.Pipeline.Idunconditionally; on/pipelines/createPipelineisnil, panicking mid-render. The panel is now guarded with{% if p.Pipeline != nil %}. (views/pipelineEditPage.qtpl)High
createSensorGroup/deleteSensorGrouppassed a bare cursor where a URL was expected (breaking infinite scroll), andgetDevicesTable/deviceListPageomittedsensor_groupfrom the next-page URL (page 2+ returned all devices). All four spots now build full…?sensor_group=&cursor=URLs (delete correctly omits the filter). (routes/overview.go)returns — badstart/endparams wrote an HTTP error then still tried to upgrade the socket on a committed response. Addedreturnafter each parse error. (routes/overview.go)Medium
updatePipelineerror handling — readresp.Bodywhenrespcould benil, fell through to a nil-deref status check, and had an unreachableerrors.Asbranch. Rewritten to be nil-safe and return after surfacing the error. Superseded by the shared error helper in the review follow-up below. (routes/pipelines.go)trace.WorkerTimes[j]could index out of range when the API returns fewer times than workers. Added a bounds guard. (routes/ingress.go)routes/workers.go)createWorkernow readsstateand sets it. (routes/workers.go)Low / robustness
middleware.Recovererso handler/template panics return a clean 500 instead of dropping the connection. (main.go)formatSincecopy ("About 1 hour ago" / "About 1 minute ago") and removed a duplicated branch. (routes/ingress.go)defer-ing in a loop. (routes/overview.go)fmt.Print*debug statements. (workers.go,pipelines.go,main.go)Review follow-ups (4249155)
A second review pass on this branch surfaced seven more findings, all fixed:
handleAPIClientErrorhelper unwrapsapi.GenericOpenAPIError, shows the API's message in the snackbar, and writes a real error status (previously update fell through to a generic snackbar with HTTP 200, so htmx treated failed saves as successful; create returned a raw HTTP error). The unreachableerrors.As(*web.APIError)branch and the deadStatusCode != StatusCreatedblock are removed. (routes/pipelines.go)updateWorkerdescription PATCH semantics — the field is only sent when present in the form (presence check viar.Form), so an omitted key no longer erases the stored description while an explicitly emptied textarea still clears it, matching the server's nil=keep / ""=clear contract. (routes/workers.go)nosurf.Reasonwith method and path, and returns 400 instead of a silent 200. (main.go)devicesTableNextPage(next, sensorGroupID)helper replaces four inline copies that sourcedsensor_groupthree different ways. (routes/overview.go)formState(r)replaces the duplicated checkbox switch increateWorker/updateWorker. (routes/workers.go)formatSincepluralization — extracted anabout(n, unit)helper; "About 1 second ago" now renders correctly and negative durations from clock skew clamp to zero. (routes/ingress.go)Verification
go build ./services/dashboard/...,go vet ./services/dashboard/..., andgofmt -lall clean.Not included (cosmetic / larger calls)
Worker name field styled to look disabled but editable; empty
200on non-HTMX table endpoints; external CDN dependencies; unescaped server data in inline<script>strings; deadTrace.PipelineName.🤖 Generated with Claude Code